package com.dc.designPattern._20_state.impl;

import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * Description: 状态模式_具体状态_发放奖品状态
 * @author: gdc
 * @date: 2021/6/9
 * @version 1.0
 */
@Data
@AllArgsConstructor
public class DispenseState implements State{

    private RaffleActivity activity;

    @Override
    public void deductMoney() {
        System.out.println("不能扣除积分");
    }

    @Override
    public boolean raffle() {
        System.out.println("不能抽奖");
        return false;
    }

    @Override
    public void dispensePrize() {
        if (activity.getCount() > 0) {
            System.out.println("恭喜中奖了...");
            // 改变状态为不能抽奖
            activity.setState(activity.getNoRaffleState());
        } else {
            System.out.println("很遗憾奖品发完了");
            // 改变奖品状态为发送完毕, 后面就不可以再抽奖了
            activity.setState(activity.getDispenseOutState());
            //System.out.println("抽奖活动结束...");
            //System.exit(0);
        }
    }
}
